<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--表单组件-->
      <el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="600px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
          <el-form-item label="北京时间" prop="beijingTime">
            <el-date-picker v-model="form.beijingTime" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1方位角" prop="oneAzimuth">
            <el-input v-model="form.oneAzimuth" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1俯仰角" prop="onePitchAngle">
            <el-input v-model="form.onePitchAngle" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1脱靶量X" prop="oneMissDistanceX">
            <el-input v-model="form.oneMissDistanceX" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1脱靶量Y" prop="oneMissDistanceY">
            <el-input v-model="form.oneMissDistanceY" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1合成方位" prop="oneCompoundOrientation">
            <el-input v-model="form.oneCompoundOrientation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1合成俯仰" prop="oneCompoundPitching">
            <el-input v-model="form.oneCompoundPitching" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="2脱靶量X">
            <el-input v-model="form.twoMissDistanceX" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="2脱靶量Y">
            <el-input v-model="form.twoMissDistanceY" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="2合成方位">
            <el-input v-model="form.twoCompoundOrientation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="2合成俯仰">
            <el-input v-model="form.twoCompoundPitching" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="3脱靶量X">
            <el-input v-model="form.threeMissDistanceX" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="3脱靶量Y">
            <el-input v-model="form.threeMissDistanceY" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="3合成方位">
            <el-input v-model="form.threeCompoundOrientation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="3合成俯仰">
            <el-input v-model="form.threeCompoundPitching" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('beijingTime')" prop="beijingTime" label="北京时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.beijingTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('oneAzimuth')" prop="oneAzimuth" label="1方位角" />
        <el-table-column v-if="columns.visible('onePitchAngle')" prop="onePitchAngle" label="1俯仰角" />
        <el-table-column v-if="columns.visible('oneMissDistanceX')" prop="oneMissDistanceX" label="1脱靶量X" />
        <el-table-column v-if="columns.visible('oneMissDistanceY')" prop="oneMissDistanceY" label="1脱靶量Y" />
        <el-table-column v-if="columns.visible('oneCompoundOrientation')" prop="oneCompoundOrientation" label="1合成方位" />
        <el-table-column v-if="columns.visible('oneCompoundPitching')" prop="oneCompoundPitching" label="1合成俯仰" />
        <el-table-column v-if="columns.visible('twoMissDistanceX')" prop="twoMissDistanceX" label="2脱靶量X" />
        <el-table-column v-if="columns.visible('twoMissDistanceY')" prop="twoMissDistanceY" label="2脱靶量Y" />
        <el-table-column v-if="columns.visible('twoCompoundOrientation')" prop="twoCompoundOrientation" label="2合成方位" />
        <el-table-column v-if="columns.visible('twoCompoundPitching')" prop="twoCompoundPitching" label="2合成俯仰" />
        <el-table-column v-if="columns.visible('threeMissDistanceX')" prop="threeMissDistanceX" label="3脱靶量X" />
        <el-table-column v-if="columns.visible('threeMissDistanceY')" prop="threeMissDistanceY" label="3脱靶量Y" />
        <el-table-column v-if="columns.visible('threeCompoundOrientation')" prop="threeCompoundOrientation" label="3合成方位" />
        <el-table-column v-if="columns.visible('threeCompoundPitching')" prop="threeCompoundPitching" label="3合成俯仰" />
        <el-table-column v-if="columns.visible('createUser')" prop="createUser" label="创建人" />
        <el-table-column v-if="columns.visible('createDate')" prop="createDate" label="创建时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('updateUser')" prop="updateUser" label="最后修改人" />
        <el-table-column v-if="columns.visible('updateDate')" prop="updateDate" label="最后修改时间" width="100px">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-permission="['admin','daSubtaskData02:edit','daSubtaskData02:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDaSubtaskData02 from '@/api/daSubtaskData02'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

// crud交由presenter持有
const defaultCrud = CRUD({ title: '数据02', url: 'api/daSubtaskData02', sort: 'id,desc', crudMethod: { ...crudDaSubtaskData02 }})
const defaultForm = { id: null, daSubtaskId: null, beijingTime: null, oneAzimuth: null, onePitchAngle: null, oneMissDistanceX: null, oneMissDistanceY: null, oneCompoundOrientation: null, oneCompoundPitching: null, twoMissDistanceX: null, twoMissDistanceY: null, twoCompoundOrientation: null, twoCompoundPitching: null, threeMissDistanceX: null, threeMissDistanceY: null, threeCompoundOrientation: null, threeCompoundPitching: null, isDelete: null, createUser: null, createDate: null, updateUser: null, updateDate: null }
export default {
  name: 'DaSubtaskData02',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  dicts: ['dept_status'],
  props: {
    data02Data: {
      type: Object,
      // default: function () { return {}} }
      default: () => {}
    }
  },
  data() {
    return {
      permission: {
        add: ['admin', 'daSubtaskData01:add'],
        edit: ['admin', 'daSubtaskData01:edit'],
        del: ['admin', 'daSubtaskData01:del']
      },
      rules: {
        daSubtaskId: [
          { required: true, message: '设备不能为空', trigger: 'blur' }
        ],
        beijingTime: [
          { required: true, message: '北京时间不能为空', trigger: 'blur' }
        ],
        oneAzimuth: [
          { required: true, message: '1方位角不能为空', trigger: 'blur' }
        ],
        onePitchAngle: [
          { required: true, message: '1俯仰角不能为空', trigger: 'blur' }
        ],
        oneMissDistanceX: [
          { required: true, message: '1脱靶量X不能为空', trigger: 'blur' }
        ],
        oneMissDistanceY: [
          { required: true, message: '1脱靶量Y不能为空', trigger: 'blur' }
        ],
        oneCompoundOrientation: [
          { required: true, message: '1合成方位不能为空', trigger: 'blur' }
        ],
        oneCompoundPitching: [
          { required: true, message: '1合成俯仰不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'daSubtaskId', display_name: '设备' }
      ]
    }
  },
  watch: {
    data02Data() {
      this.query.daDataFileSf = this.data02Data.systemFilename
      this.crud.refresh()
    }
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      const query = this.query
      query.daDataFileSf = this.data02Data.systemFilename
      if (query.type && query.value) {
        this.crud.params[query.type] = query.value
      }
      return true
    }
  }
}
</script>

<style scoped>

</style>
